/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package varx.lms.model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import varx.lms.SessionManager;

/**
 *
 * @author FF
 */
public class FormModel extends Model{

    Connection conn;
    
    public FormModel(String tableName) {
        super(tableName);
    }

    public FormModel() {
        super("form");
        this.conn=SessionManager.getConnection();
    }
    
    
    //formADD,formDel,formUpdate,formSearch
//    public int add(int from,int to,int volume){
//        String sql="INSERT INTO  `lms`.`form` (`from_id` ,`user_id` ,`warehouse_id` ,`to_id`)VALUES ( ?,  ?,  ?,  ?);";
//        try {
//            preparedStatement=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
//            preparedStatement.setInt(1, from);
//            preparedStatement.setInt(4, to);
//            preparedStatement.setInt(3, WarehouseDAO.getFreeWarehouser(volume));
//            preparedStatement.setInt(2, SessionManager.getUid());
//            preparedStatement.executeUpdate();
//            ResultSet rs=preparedStatement.getGeneratedKeys();
//            if(rs.next()){
//                int id=rs.getInt(1);
//                return id;
//            }else
//                return 0;
//        } catch (SQLException ex) {
//            Logger.getLogger(FormModel.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        return 0;
//    }
    
    
    public static  ResultSet findFormByCustomer(String customer_id){
        ResultSet resultSet=null;
        String sql="SELECT * FROM `form` WHERE `customer_id` ="+customer_id;
        try {
            return SessionManager.getConnection().createStatement().executeQuery(sql);
        } catch (SQLException ex) {
            System.out.println(ex);
        }
        return resultSet;
    }
   
    
}